﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Speech.Recognition;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace DigiMate
{
	public class SpeechReco
	{
		static CultureInfo Culture = new CultureInfo("en-us");
		static SpeechRecognitionEngine reco = null;
		static RecognizerInfo recognizerInfo = null;

		public static void InitRecognizerInfo()
		{
			foreach (RecognizerInfo ri in SpeechRecognitionEngine.InstalledRecognizers())
			{
				if ((ri.Culture.TwoLetterISOLanguageName.Equals("en")) && (recognizerInfo == null))
				{
					recognizerInfo = ri;
				}
			}
		}

		public static SpeechRecognitionEngine GetReco()
		{
			InitRecognizerInfo();

			reco = new SpeechRecognitionEngine(recognizerInfo);
			reco.SetInputToDefaultAudioDevice();
			
			return reco;
		}

	}
}
